//Credit : - uzzy
//https://atcoder.jp/contests/abc149/submissions/9246797
#include <bits/stdc++.h>
#include<cstdio>
 
typedef long long ll;
using namespace std;
 
const int NAX = 2e5 + 10;
 
int n;
pair<int, int> a[NAX];
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
 
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
 
int main() {
//  ios_base::sync_with_stdio(false);
  //cin.tie(NULL);
  n = getint(); 
  for(int i=0; i<n; ++i) {
      a[i].first = getint();
      a[i].second = getint();
  }
  sort(a, a+n);
  int res = 1, curr = a[0].second;
  for(int i=1; i<n; ++i) {
      curr = min(curr, a[i].second);
      if(curr <= a[i].first) ++res, curr = a[i].second;
  }
  printf("%d\n", res);
  return 0;
}
